package com.tangyuan.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * @Description: user_balance
 * @Author: jeecg-boot
 * @Date:   2024-03-12
 * @Version: V1.0
 */
@Data
@TableName("user_balance")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
public class UserBalance implements Serializable {
    private static final long serialVersionUID = 1L;

	/**id*/
	@TableId(type = IdType.AUTO)
    private Long id;
	/**用户id*/
    private Long userId;
	/**类型 1-充值 2-付款 3-退款 4-提现*/
    private Integer type;
	/**第三方订单号*/
    private String transactionId;
	/**订单号*/
    private String orderNo;
	/**增加或减少的金额*/
    private BigDecimal upBalance;
	/**增加或减少的金额 后账户余额*/
    private BigDecimal balance;
	/**createTime*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date createTime;
	/**updateTime*/
	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
	/**isDelete*/
    @TableLogic
    private Integer isDelete;
    private Integer status;
    /**
     * 检查UserBalance对象是否所有属性都为空或默认值。
     * @return 如果所有相关属性都为空或默认值，则返回true；否则返回false。
     */
    public boolean isEmpty() {
        return id == null
                && userId == null
                && type == null
                && (transactionId == null || transactionId.isEmpty())
                && orderNo == null
                && upBalance == null
                && balance == null
                && createTime == null
                && updateTime == null
                && ((isDelete == null) || (isDelete != null && isDelete == 0)) // 逻辑删除字段处理
                && status == null;
    }
}
